import { SerializeStream } from "../../Framework/Serialize/SerializeStream";
import { SeqRouterMapHelper } from "./SeqRouterMapHelper";
import { ERMICallModel } from "./ERMICallModel";
import { SIdentity } from "./SIdentity";
import {
  StreamDispacher,
  StreamDispacherDataType
} from "../../flash/events/StreamDispacher";
type int = number;
//class SRMICall

export class SRMICall extends StreamDispacher {
  constructor() {
    super([
      {
        key: "messageId",
        type: StreamDispacherDataType.Int
      },
      {
        key: "callSynchType"
      }
    ]);
  }
  public __write(stream: SerializeStream): void {
    super.__write(stream);
    this.callSynchType.__write(stream);
    this.identity.__write(stream);
    stream.writeString(this.operation);
    stream.writeInt(this.userKey);
    SeqRouterMapHelper.write(stream, this.routerMap);
  }

  public __read(stream: SerializeStream): void {
    super.__read(stream);
    this.callSynchType = ERMICallModel.__read(stream);
    this.identity = new SIdentity();
    this.identity.__read(stream);
    this.operation = stream.readString();
    this.userKey = stream.readInt();
    this.routerMap = SeqRouterMapHelper.read(stream);
  }

  public messageId!: int;
  public callSynchType!: ERMICallModel;
  public identity!: SIdentity;
  public operation!: string;
  public userKey!: int;
  public routerMap!: Array<int>;
}
